delete from [TradingData].[BookSecurityToBenchmark]

delete [TradingData].TimeSerie from [TradingData].TimeSerie as t 
inner  JOIN [TradingData].Security as s on s.id = t.SecurityId
inner Join [TradingData].BenchmarkList as b on b.SecurityId = s.Id


DECLARE @TempTable TABLE
(
   id int
);
INSERT INTO   @TempTable 
SELECT DISTINCT s.Id FROM [TradingData].Security as s 
inner Join [TradingData].BenchmarkList as b on b.SecurityId = s.Id

delete from [TradingData].ExcessTimeSerie
delete from [TradingData].BenchmarkList


delete  [TradingData].Security from  [TradingData].Security as s 
inner Join @TempTable as t on t.id = s.Id

 delete   FROM [Settings].[Parameters] where [Type] = 'Invest.TradingData.DataHandlers.Models.ValidDateRangeProcessorModels.ProcessedTimeSeries'
delete   FROM [Settings].[Parameters] where [Type] = 'Invest.TradingData.DataHandlers.Models.ValidDateRangeProcessorModels.ProcessedCorporateEvents'

 delete   FROM [Settings].[Parameters] where [Type] = 'Invest.TradingData.ValidDateRangeProcessorModels.ProcessedTimeSeries'
delete   FROM [Settings].[Parameters] where [Type] = 'Invest.TradingData.ValidDateRangeProcessorModels.ProcessedCorporateEvents'




 delete FROM [Clients_Hermes].[TradingData].[FxSerie]
 delete FROM [Clients_Hermes].[TradingData].TimeSerie
 delete FROM [Clients_Hermes].[TradingData].ExcessTimeSerie